package org.yoki.edu.common.protocol.radius.attribute.attr.check;


import lombok.Getter;
import org.yoki.edu.common.protocol.radius.attribute.attr.type.IntegerTypeAttr;

/**
 * @author Sky$
 * @Description: TODO
 * @date 2018/1/15$ 14:54$
 */
public class ServiceTypeAttr extends IntegerTypeAttr {

    public static final int ATTR_TYPE = 6;

    @Override
    public int getAttrType() {
        return ATTR_TYPE;
    }

    public ServiceTypeEnum getServiceType() {
        return ServiceTypeEnum.getByValue(this.value);
    }

    public enum ServiceTypeEnum {

        Login(1, "Login"),
        Framed(2, "Framed"),
        CallbackLogin(3, "Callback Login"),
        CallbackFramed(4, "Callback Framed"),
        Outbound(5, "Outbound"),
        Administrative(6, "Administrative"),
        NASPrompt(7, "NAS Prompt"),
        AuthenticateOnly(8, "Authenticate Only"),
        CallbackNASPrompt(9, "Callback NAS Prompt"),
        CallCheck(10, "Call Check"),
        CallbackAdministrative(11, "Callback Administrative");

        @Getter
        private int value;
        @Getter
        private String name;

        ServiceTypeEnum(int value, String name) {
            this.value = value;
            this.name = name;
        }

        public static ServiceTypeEnum getByValue(Integer value) {
            if (null == value) {
                throw new IllegalArgumentException();
            }
            ServiceTypeEnum[] enums = ServiceTypeEnum.values();
            for (ServiceTypeEnum e : enums) {
                if (e.getValue() == value.intValue()) {
                    return e;
                }
            }
            return null;
        }

    }
}


